package com.itheima.manager.service;

import com.itheima.manager.dao.DiTieDao;
import com.itheima.manager.domain.DitieZhan;

import java.util.ArrayList;

public class DiTieService {
    private DiTieDao dtd = new DiTieDao();

    public ArrayList<DitieZhan> selectDiTieZhan() {
        ArrayList<DitieZhan> ditieZhans = dtd.selectDiTieZhan();
        if (ditieZhans.size() > 0) {
            return ditieZhans;
        } else {
            return null;
        }
    }

    public boolean isExist(String id) {
        boolean flag = false;
        ArrayList<DitieZhan> ditieZhans = dtd.selectDiTieZhan();
        for (DitieZhan ditieZhan : ditieZhans) {
            if (ditieZhan != null && ditieZhan.getId().equals(id)) {
                flag = true;
            }
        }
        return flag;
    }

    public boolean addDiTieZhan(DitieZhan dt) {
        return dtd.addDiTieZhan(dt);
    }

    //删除地铁信息
    public void deleteDiTieZhan(String id) {
        dtd.deleteDiTieZhan(id);
    }

    //修改地铁站信息
    public void updateDiTieZhan(String id,DitieZhan ditieZhan) {
        dtd.updateDiTieZhan(id,ditieZhan);
    }
}
